package com.zlx.guguanjia.controller;

import com.github.pagehelper.PageInfo;
import com.zlx.guguanjia.entity.Qualification;
import com.zlx.guguanjia.entity.QualificationConfiguration;
import com.zlx.guguanjia.entity.Result;
import com.zlx.guguanjia.service.QualificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 周罗校
 * @Description
 * @ClassName QualificationController
 * @date 2020.10.26 12:22:01
 * 该版权归周罗校所有，最终解释权以官方为准
 */

@RestController
@RequestMapping("/manager/qualification")
public class QualificationController {

    @Autowired
    private QualificationService service;

    @GetMapping("selectPage/{start}/{pageSize}")
    public Result selectPage(@PathVariable("start") int start,@PathVariable("pageSize") int pageSize,QualificationConfiguration configuration){
        PageInfo<Qualification> pageInfo = service.selectPage(start, pageSize, configuration);
        return new Result(pageInfo);
    }

    @GetMapping("selectOne/{id}")
    public Result selectOne(@PathVariable("id") long id){
        return new Result(service.selectOne(id));
    }

    @PutMapping("updateStatus")
    public Result updateStatus(@RequestBody Qualification qualification){
        qualification.setAddress(null);
        return new Result(service.updateByPrimaryKeySelective(qualification));
    }
}
